﻿package Libs {
	import alternativa.engine3d.core.Object3D;
	
	import com.hexagonstar.util.debug.Debug;
	
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.EventDispatcher;
	import flash.geom.Matrix3D;
	import flash.geom.Vector3D;
	
	/**
	 * Abstract universal render adapter interface
	 * @author Exey Panteleev
	 */
	public class myLib
	{
		public function get GRID_Y_FIX():int { return -1 };
		
		// Math utils
		public static const toDEGREES:Number = 180/Math.PI;
		public static const toRADIANS:Number = Math.PI / 180;
		
		protected const _FORWARD  	:Vector3D = new Vector3D(  0,  0,  1 );
		protected const _BACKWARD  	:Vector3D = new Vector3D(  0,  0,  -1 );
		public function get FORWARD():Vector3D { return _FORWARD; };
		public function get BACKWARD():Vector3D { return _BACKWARD; };
		
		public function rotateAxis( matrix3D:Matrix3D, vector3D:Vector3D ):void {
			var vx:Number = vector3D.x;
			var vy:Number = vector3D.y;
			var vz:Number = vector3D.z;

			vector3D.x = vx * matrix3D.rawData[0] + vy * matrix3D.rawData[4] + vz * matrix3D.rawData[8];
			vector3D.z = vx * matrix3D.rawData[2] + vy * matrix3D.rawData[6] + vz * matrix3D.rawData[10];
			vector3D.y = vx * matrix3D.rawData[1] + vy * matrix3D.rawData[5] + vz * matrix3D.rawData[9];
			
			vector3D.normalize();
		}
	 public static function log(tmp:Object3D):void{
		 Debug.trace(tmp.x + "," + tmp.y + "," + tmp.z);
	 }
	 public static function rand(min:int, max:int):int
	 {
		 return Math.floor(Math.random() * (max - min + 1) + min);
	 }
	}
}